Hi all, |
Re: Ideas for comparing 2 tables from 2 different modules...
Below is a quick hack for the problem using skip lists. It only works if the tables are identical in size.
// Quick hack for comparing two tables
/*
Open the two modules, select cells in the two tables and run the script
*/
string modName_1 = "" // Add module name here
string modName_2 = "" // Add module name here
Module mod_1 = null
Module mod_2 = null
Object currObj_1, currObj_2
Object tableObj_1 = null
Object tableObj_2 = null
Object rowObj, cellObj_1, cellObj_2
Skip sList_1 = create
Skip sList_2 = create
int nKey
int nCells_1, nCells_2
// Get handle for the two modules
if (exists module modName_1 && exists module modName_2)
{ // Modules exist
if (open module modName_1){mod_1 = module item modName_1}
if (open module modName_2){mod_2 = module item modName_2}
} // Modules exist
if (null mod_1 || null mod_2){print "One of the modules is not open."; halt}
// Get current objects
currObj_1 = current(mod_1)
currObj_2 = current(mod_2)
if (cell currObj_1){tableObj_1 = getTable(currObj_1)}
if (cell currObj_2){tableObj_2 = getTable(currObj_2)}
if (null tableObj_1 || null tableObj_2){print "No cell selected in one of the modules"}
else
{ // Two cells selected
// Store cell objects in Skip lists
nKey = 0
for rowObj in tableObj_1 do{for cellObj_1 in rowObj do{put(sList_1, nKey++, cellObj_1)}}
nCells_1 = nKey
nKey = 0
for rowObj in tableObj_2 do{for cellObj_2 in rowObj do{put(sList_2, nKey++, cellObj_2)}}
nCells_2 = nKey
if (nCells_1 != nCells_2){print "Different table sizes!\n"}
for cellObj_1 in sList_1 do
{ // Loop through first table's cell objects
print (name module cellObj_1) " #" cellObj_1."Absolute Number" " "
nKey = (int key sList_1)
if (!find(sList_2, nKey, cellObj_2)){print "No matching cell found\n"}
else
{ // Matching cell found in second table
print (name module cellObj_2) " #" cellObj_2."Absolute Number" ": "
if (cellObj_1."Object Text" "" != cellObj_2."Object Text" "")
{ // Cells' Object Text differs
print "Cells differ\n"
// Create the desired links here
} // Cells' Object Text differs
else
{ // Cells' Object Text are identical
print "Cells are identical\n"
} // Cells' Object Text are identical
} // Matching cell found in second table
} // Loop through first table's cell objects
} // Two cells selected
delete sList_1
delete sList_2
|
Re: Ideas for comparing 2 tables from 2 different modules... Object objA //object for table in module A Object objB //object for table in module B Object roModuleA //row Object coModuleA //cell Object roModuleB //row Object coModuleB //cell int iNumRowToCompairA = 0 int iNumColumnToCompairA = 0 int iNumRowToCompairB = 0 int iNumColumnToCompairB = 0 for roModuleA in table(objA) do { ++iNumColumnToCompairA iNumColumnToCompairB = 0 for roModuleB in table(objB) do { ++iNumColumnToCompairB if ( iNumColumnToCompairA != iNumColumnToCompairB ) continue for coModuleA in row(roModuleA) do { ++iNumRowToCompairA iNumRowToCompairB = 0 for coModuleB in row(roModuleB) do { ++iNumRowToCompairB if ( iNumRowToCompairA != iNumRowToCompairB ) continue if ( coModuleA."Object Text" "" == coModuleB."Object Text" "" ) print coModuleA."Object Text" " found\n" } } } } |
Re: Ideas for comparing 2 tables from 2 different modules... Peter_Albert - Fri Jul 03 04:38:29 EDT 2009
Below is a quick hack for the problem using skip lists. It only works if the tables are identical in size.
// Quick hack for comparing two tables
/*
Open the two modules, select cells in the two tables and run the script
*/
string modName_1 = "" // Add module name here
string modName_2 = "" // Add module name here
Module mod_1 = null
Module mod_2 = null
Object currObj_1, currObj_2
Object tableObj_1 = null
Object tableObj_2 = null
Object rowObj, cellObj_1, cellObj_2
Skip sList_1 = create
Skip sList_2 = create
int nKey
int nCells_1, nCells_2
// Get handle for the two modules
if (exists module modName_1 && exists module modName_2)
{ // Modules exist
if (open module modName_1){mod_1 = module item modName_1}
if (open module modName_2){mod_2 = module item modName_2}
} // Modules exist
if (null mod_1 || null mod_2){print "One of the modules is not open."; halt}
// Get current objects
currObj_1 = current(mod_1)
currObj_2 = current(mod_2)
if (cell currObj_1){tableObj_1 = getTable(currObj_1)}
if (cell currObj_2){tableObj_2 = getTable(currObj_2)}
if (null tableObj_1 || null tableObj_2){print "No cell selected in one of the modules"}
else
{ // Two cells selected
// Store cell objects in Skip lists
nKey = 0
for rowObj in tableObj_1 do{for cellObj_1 in rowObj do{put(sList_1, nKey++, cellObj_1)}}
nCells_1 = nKey
nKey = 0
for rowObj in tableObj_2 do{for cellObj_2 in rowObj do{put(sList_2, nKey++, cellObj_2)}}
nCells_2 = nKey
if (nCells_1 != nCells_2){print "Different table sizes!\n"}
for cellObj_1 in sList_1 do
{ // Loop through first table's cell objects
print (name module cellObj_1) " #" cellObj_1."Absolute Number" " "
nKey = (int key sList_1)
if (!find(sList_2, nKey, cellObj_2)){print "No matching cell found\n"}
else
{ // Matching cell found in second table
print (name module cellObj_2) " #" cellObj_2."Absolute Number" ": "
if (cellObj_1."Object Text" "" != cellObj_2."Object Text" "")
{ // Cells' Object Text differs
print "Cells differ\n"
// Create the desired links here
} // Cells' Object Text differs
else
{ // Cells' Object Text are identical
print "Cells are identical\n"
} // Cells' Object Text are identical
} // Matching cell found in second table
} // Loop through first table's cell objects
} // Two cells selected
delete sList_1
delete sList_2
|
Re: Ideas for comparing 2 tables from 2 different modules... gpolley - Fri Jul 03 07:14:23 EDT 2009 First, you don't have to select all cells in all tables but rather one cell in each table. But still for hundreds of tables this is not feasible. You can easily modify the script to a routine accepting two table header objects as input variables. Your task then is to identify the respective table header objects. The solution for this depends on your actual situation, i.e. are the tables in the same module or in different modules, are they in the same order or in different order, etc ...? Peter |
Re: Ideas for comparing 2 tables from 2 different modules... Peter_Albert - Fri Jul 03 07:25:40 EDT 2009 |